/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jellyfishumbrella.GL;

import java.util.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.*;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import java.awt.geom.*;
import org.lwjgl.util.vector.*;
import java.util.concurrent.*;
import java.nio.*;
import org.lwjgl.BufferUtils;

/**
 * 
 * @author 500441547
 */
public class Material {
	private  FloatBuffer tempBuffer = BufferUtils.createFloatBuffer(4);
	private  float[] amb;
	private  float[] diff;
	private  float[] spec;
	private  float gloss;

	public Material() {

	}

	public Material(float[] ambColor, float[] diffColor, float[] specColor, float glossy) {
		amb = ambColor;
		diff = diffColor;
		spec = specColor;
		gloss = glossy;
	}

	public void render() {
		loadTempBuffer(amb);
		glMaterial(GL_FRONT_AND_BACK, GL_AMBIENT, tempBuffer);
		loadTempBuffer(diff);
		glMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE, tempBuffer);
		loadTempBuffer(spec);
		glMaterial(GL_FRONT_AND_BACK, GL_SPECULAR, tempBuffer);
		glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, gloss);
	}

	private void loadTempBuffer(float[] data) {
		tempBuffer.rewind();
		tempBuffer.put(data);
		tempBuffer.flip();
	}
}
